<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加分类</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <script src="js/jquery.min.js"></script>
</head>
<body>
<form onsubmit="return false" id="lists" action="##" method="get">
    <div>
        <span>数据id输入</span>
        <input type="text" name="cid">
    </div>
    <div>
        <span>数据表内类名输入</span>
        <input type="text" name="cname">
    </div>
     <button type="button" id="btn">提交</button>
</form>
<script>
    $("#btn").click(function () {
        $.ajax({
            url: "/admin/addCates",
            type : "GET",
            dataType: "json",//预期服务器返回的数据类型
            data: $("#lists").serialize(),
            success: function (result) {
                console.log(result);//打印服务端返回的数据(调试用)
                if (result.code == 200) {
                    alert("成功！")
                }
            },
            error: function () {
                alert("失败")
            }
        });
    })
</script>
</body>
</html>